import allure
from selenium.webdriver.common.by import By

from base.base import Base


class pageLogin(Base):
    # 输入用户名
    @allure.step('1.输入用户名')
    def __input_username(self,username):
        self.element_send_keys((By.ID,"username"),username)

    # 输入密码
    @allure.step('2.输入密码')
    def __input_password(self,password):
        self.element_send_keys((By.ID,"password"),password)

    #输入验证码
    @allure.step('3.输入验证码')
    def __input_verify_code(self,code):
        self.element_send_keys((By.ID,"verify_code"),code)

    #  点击登录
    @allure.step('4.点击登录按钮')
    def __click_login_button(self):
        self.element_click((By.NAME,"sbtbutton"))
#  获取当前页面的url
#     def __current_url(self):
#         self.element_get_url()

#  获取文本
    def get_error_text(self):
      return  self.get_text((By.CSS_SELECTOR,'.layui-layer-content.layui-layer-padding'))


    def login(self,username,password,code):
        self.__input_username(username)#输入用户名
        self.__input_password(password)#输入密码
        self.__input_verify_code(code)#输入验证码
        self.__click_login_button()#点击登录按钮






